package Feb_10.Task;

import Jan_19.TestOBJ;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;

public class Task5 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Task5_1.student> list = new ArrayList<>();
        while (true){
            System.out.print("输入学号：");
            int id = Integer.parseInt(scanner.nextLine());
            System.out.print("输入姓名：");
            String name = scanner.nextLine();
            System.out.print("输入性别：");
            String gender = scanner.nextLine();
            list.add(new Task5_1.student(id,name,gender));
            System.out.print("继续？（y/n）：");
            String next =scanner.nextLine();
            if (Objects.equals(next,"y")){
            }else {
                break;
            }
        }
        File file = new File("E:/student.dat");
        try (FileOutputStream fileOutputStream = new FileOutputStream(file);
             ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)){
            objectOutputStream.writeObject(list);
            objectOutputStream.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
